import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch((err) => err);
};

const routes = [
    {
        path: '/',
        name: 'lyout',
        component: () => import(/* webpackChunkName: "about" */ '../components/lyout/index.vue'),
        children: [
            {
                path: '',
                redirect: 'userInfo'
            },
            {
                path: 'userInfo',
                name: 'userInfo',
                component: () => import(/* webpackChunkName: "about" */ '../views/userInfo.vue')
            },
            {
                path: 'video',
                name: 'video',
                component: () => import(/* webpackChunkName: "about" */ '../views/video.vue')
            },
            {
                path: 'datas',
                name: 'datas',
                component: () => import(/* webpackChunkName: "about" */ '../views/datas.vue')
            }
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
    },
    {
        path: '/register',
        name: 'register',
        component: () => import(/* webpackChunkName: "about" */ '../views/register.vue')
    }
];

const router = new VueRouter({
    routes
});

export default router;
